import { fileURLToPath, URL } from 'node:url'
import { resolve } from 'path'
import { defineConfig } from 'vite'
import { createVuePlugin } from 'vite-plugin-vue2'

// https://vitejs.dev/config/
export default defineConfig({
  base: '/',
  plugins: [createVuePlugin()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
    extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".vue"]
  },
  server: {
    port: 8082,
    host: '0.0.0.0',
    proxy: {}
  },
  build: {
    assetsInlineLimit: 2048,
    outDir: './lib/',
    sourcemap: false,
    rollupOptions: {
      external: ['vue'],
    },
    lib: {
      entry: resolve(__dirname, 'src/index.js'),
      name: 'CustomDesigner',
      formats: ['es', 'umd'],
      fileName: (format) => `CustomDesigner.${format}.js`
    },
  },
})
